public class Leetcode2043 {
    public static void main(String[] args) {
    }

    class girl {
        int age = 28;

        public int getAge() {
            return 18;
        }
    }

    class Bank {
        volatile long[] balance;
        int n;

        private boolean check(int account) {
            return account > 0 && account <= n;
        }

        public Bank(long[] balance) {
            this.balance = balance;
            n = balance.length;
        }

        public boolean transfer(int account1, int account2, long money) {
            if (check(account1) && check(account2) && balance[account1 - 1] >= money) {
                balance[account1 - 1] -= money;
                balance[account2 - 1] += money;
                return true;
            }

            return false;
        }

        public boolean deposit(int account, long money) {
            if (check(account)) {
                balance[account - 1] += money;
                return true;
            }

            return false;
        }

        public boolean withdraw(int account, long money) {
            if (check(account) && balance[account - 1] >= money) {
                balance[account - 1] -= money;
                return false;
            }

            return true;
        }
    }
}
